home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Libris Britannia 4
/
science library(b).zip
/
science library(b)
/
DDJMAG
/
DDJ9207.ZIP
/
AVK.ASC
< prev
next >
Wrap
Text File
|
1992-06-15
|
23KB
|
754 lines
_CAPTURING DIGITAL VIDEO USING DVI_
by James L. Green
[LISTING ONE]
//--- AvkCapt.h Copyright Intel Corp. 1991, 1992, All Rights Reserved ---
#include "avkapi.h"
// File name for the RTV 2.0 VSH data file (from avkalg.h)
#define VSHFILE_NAME AVK_RTV_20_ENCODE_DATA_NAME
// A couple of shorthand AVK #defines for convenience
#define OK AVK_ERR_OK
#define NOW AVK_TIME_IMMEDIATE
#define HNULL ((HAVK)0)
// Values for capturing
#define AUD_SAMPLE_RATE (U32)33075
#define FRAME_RATE (U32)33367
// Size of Capture Data Buffers
#define VID_BUF_SIZE (256L * 1024L)
#define VID_BUF_GRAN ( 64L * 1024L)
#define AUD_BUF_SIZE (128L * 1024L)
#define AUD_BUF_GRAN ( 16L * 1024L)
#define HOST_BUF_SIZE 32768U
// Maximum number of iterations of the capture loop
// before we are forced back to the main message loop
#define CAPTURE_LOOPS 10
// ID value for the capture Windows timer
#define TIMER_ID 1
// Number of milliseconds between timer ticks
#define TIMER_INTERVAL 500
// States for the capture engine
#define ST_UNINITIALIZED 0
#define ST_INITIALIZED 1
#define ST_MONITORING 2
#define ST_CAPTURING 3
// Control structure for the current view
typedef struct tagVIEW
{
HAVK hView; // AVK View handle
HAVK hConnDigi2Strm; // Digitizer to Video Stream connector
HAVK hConnStrm2View; // Video Stream to View connector
BOOL bConnEnabled; // TRUE if the connector is enabled
WORD DviMonitorSync; // DviMonitorSync value from AVK.INI
I16 cxView; // View's x resolution
I16 cyView; // View's y resolution
double xDelta; // used to convert screen
double yDelta; // coords to view
I16 cxScreen; // physical screen's x resolution
I16 cyScreen; // physical screen's y resolution
U16 VidType; // View's video type
U16 BmFmt; // View's bitmap format
BOOL bIsKeyed; // TRUE if the View is keyed
BOX SrcBox; // connector's source rectangle
BOX DstBox; // connector's destination rectangle
} VIEW;
// Control structure for capture buffers
typedef struct tagCAPT
{
HAVK hGrpBuf; // group buffer handle
HAVK hStrm; // stream handle
char far *pBufHead; // host RAM I/O buffer
char far *pBufCurr; // current position in host I/O buffer
U32 BufDataCnt; // amount of data in host I/O buffer
} CAPT;
// Structure for storing sync resolutions. The sync table
// will be an array of VIDEO_SYNC structures called Syncs[].
typedef struct tagVIDEO_SYNC
{
WORD xResRTV; // RTV capture x resolution
WORD xResVid; // Video stream premonitor x resolution
WORD yResVid; // Video stream premonitor y resolution
WORD FrameRate;
WORD PixelAspect;
} VIDEO_SYNC;
// These sync values are subscripts into a table of VIDEO_SYNC structures
#define SYNC_NTSC 0
#define SYNC_PAL 1
[LISTING TWO]
// ---- Windows AVK Capture Program - Create Recorder ----------------
// ---- Copyright Intel Corp. 1991, 1992, All Rights Reserved ---------
extern HWND hwndMain;
extern VIDEO_SYNC Syncs[];
// Local variables
static WORD State = ST_UNINITIALIZED; // current state of capture engine
WORD CaptureSync = SYNC_NTSC; // default to NTSC
char far *pVshBuf = NULL; // buffer for reading VSH data.
U32 VshSize; // size of the VSH data
VIEW View; // view control structure
AVIO_SUM_HDR Avio; // master control struct for AVSS file I/O
CAPT Vid; // video capture control structure
CAPT Aud; // audio capture control structure
I16 AvkRet; // general AVK return code variable
// RTV 2.0 encoding arguments
AVK_RTV_20_ENCODE_ARGS Rtv20Args =
{
12, // argument count
AVK_RTV_2_0, // algorithm size
0,0, // x,y coords of origin
128, 240, // xLength, yLength
3, // still period
0, 0, // bytes,lines
AVK_RTV_20_PREFILTER | AVK_RTV_20_ASPECT_25, // flags
0, 0 // quantization values
};
// AVK handles
HAVK hAvk = (HAVK)0;
HAVK hDev = (HAVK)0;
HAVK hGrp = (HAVK)0;
// Create AVK session and initialize the device
BOOL InitAvk()
{
if (!IsState(ST_UNINITIALIZED))
return TRUE;
// Start an AVK session with messaging
if ((AvkRet = AvkBeginMsg(hwndMain, &hAvk,
AVK_SESSION_DEFAULT)) != OK)
return DispAvkErr(AvkRet, "AvkBeginMsg");
// Open the ActionMedia(R) device
if ((AvkRet = AvkDeviceOpen(hAvk, 0,
AVK_DEV_OPEN_EXCLUSIVE, &hDev)) != OK)
return DispAvkErr(AvkRet, "AvkDeviceOpen");
// Get the capture sync by calling AvkDeviceVideoIn()
if ((AvkRet = AvkDeviceVideoIn(hDev, AVK_CONN_DIGITIZER)) != OK)
return DispAvkErr(AvkRet, "AvkDeviceVideoIn");
return TRUE;
}
// Check device capabilities and build the recorder
BOOL CreateAvkResources(WORD NewCaptureSync)
{
switch (NewCaptureSync)
{
case AVK_SYNC_NTSC: CaptureSync = SYNC_NTSC; break;
case AVK_SYNC_PAL: CaptureSync = SYNC_PAL; break;
}
// Get the AVK device capabilities from AVK.INI
if (!GetDevCaps(&View))
return FALSE;
if (!CreateView(&View))
return FALSE;
// The Vsh file contains data used in compressing
// the incoming motion video into an RTV 2.0 file.
if (!LoadVshFile())
return FALSE;
if (!CreateCaptureGroup())
return FALSE;
ToState(ST_INITIALIZED);
return TRUE;
}
// Get the device capabilities from AVK
BOOL GetDevCaps(VIEW *pView)
{
DVICAPS DevCaps;
// Get the physical screen resolution from the system
pView->cxScreen = GetSystemMetrics(SM_CXSCREEN);
pView->cyScreen = GetSystemMetrics(SM_CYSCREEN);
// Get the AVK device capabilities which were set in AVK.INI
if ((AvkRet = AvkGetDevCaps(0, sizeof(DevCaps), &DevCaps)) != OK)
return DispAvkErr(AvkRet, "AvkGetDevCaps");
if (DevCaps.DigitizerRevLevel == 0)
return DispErr("GetDevCaps",
"Digitizer needed for capturing - check AVK.INI");
if (DevCaps.DviMonitorSync & 0x10) // VGA
{
pView->cxView = 256;
pView->cyView = 240;
pView->VidType = AVK_VID_VGA_KEYED;
pView->bIsKeyed = TRUE;
}
else if (DevCaps.DviMonitorSync & 0x100) // XGA
{
pView->cxView = 256;
pView->cyView = 192;
pView->VidType = AVK_VID_XGA_KEYED;
pView->bIsKeyed = TRUE;
}
else if (DevCaps.DviMonitorSync & 0x02) // PAL
{
pView->cxView = 306;
pView->cyView = 288;
pView->VidType = AVK_VID_PAL;
}
else if (DevCaps.DviMonitorSync & 0x01) // NTSC
{
pView->cxView = 256;
pView->cyView = 240;
pView->VidType = AVK_VID_NTSC;
}
else
return DispErr("GetDevCaps", "Invalid monitor sync");
// Calculate Screen-To-AVK coordinate conversion deltas.
pView->xDelta = (double)pView->cxView / (double)pView->cxScreen;
pView->yDelta = (double)pView->cyView / (double)pView->cyScreen;
return TRUE;
}
// Create and display an AVK View
static BOOL CreateView(VIEW *pView)
{
if ((AvkRet = AvkViewCreate(hDev, pView->cxView, pView->cyView,
AVK_YUV9, pView->VidType, &pView->hView)) != OK)
return DispAvkErr(AvkRet, "AvkViewCreate");
// Display the View
if ((AvkRet = AvkViewDisplay(hDev, pView->hView, NOW,
AVK_VIEW_DISPLAY_DEFAULT)) != OK)
return DispAvkErr(AvkRet, "AvkViewDisplay");
// Set the destination box for the stream-to-view connector
if (!SetDstBox(hwndMain))
return FALSE;
return TRUE;
}
// Set the destination box for the stream-to-view connector
BOOL SetDstBox(HWND hwndMain)
{
RECT WinRect;
BOX NewDstBox;
GetClientRect(hwndMain, (LPRECT)&WinRect);
ClientToScreen(hwndMain, (LPPOINT)&WinRect);
WinRect.right = WinRect.left + (View.cxScreen >> 1) - 1;
WinRect.bottom = WinRect.top + (View.cyScreen >> 1) -1;
WinRect2AvkBox(&WinRect, &NewDstBox, &View);
if (View.hConnStrm2View)
{
if ((AvkRet = AvkConnHide(View.hConnStrm2View, NOW)) != OK)
return DispAvkErr(AvkRet, "AvkConnHide");
if ((AvkRet = AvkViewCleanRect(View.hView,
&View.DstBox)) != OK)
return DispAvkErr(AvkRet, "AvkViewCleanRect");
// Reset the destination of the connector to our new box
if ((AvkRet = AvkConnModSrcDst(View.hConnStrm2View, NULL,
&NewDstBox, NOW)) != OK)
return DispAvkErr(AvkRet, "AvkConnModSrcDst");
if ((AvkRet = AvkConnEnable(View.hConnStrm2View, NOW)) != OK)
return DispAvkErr(AvkRet, "AvkConnEnable");
}
// Copy new destination coords into the view's destination box
COPYBOX(&View.DstBox, &NewDstBox);
return TRUE;
}
// Get the standard VSH file that comes with AVK
static BOOL LoadVshFile()
{
int fhVsh;
OFSTRUCT Of;
// Open the VSH file
if ((fhVsh = OpenFile(VSHFILE_NAME, &Of, OF_READ)) == -1)
return DispErr("LoadVshFile",
"Unable to find the file KE080200.VSH");
VshSize = filelength(fhVsh);
// Range check - Reject if VshSize == 0 or VshSize > 65535L
if (!VshSize || VshSize & 0xffff0000)
return DispErr("LoadVshFile", "VSH file too large to load");
// Allocate a buffer to stash the VSH file.
if ((pVshBuf = MemAlloc((WORD)VshSize)) == NULL)
return DispErr("LoadVshFile",
"Unable to allocate VSH file buffer");
// Read the VSH data from the file
if (_lread(fhVsh, pVshBuf, (WORD)VshSize) != (WORD)VshSize)
return DispErr("LoadVshFile", "Unable to read VSH file");
return TRUE;
}
// Create Capture Group and resources needed for premonitoring
static BOOL CreateCaptureGroup()
{
if ((AvkRet = AvkGrpCreate(hDev, &hGrp)) != OK)
return DispAvkErr(AvkRet, "AvkGrpCreate");
if ((AvkRet = AvkGrpBufCreate(hGrp, AVK_BUF_CAPTURE, VID_BUF_SIZE,
VID_BUF_GRAN, 1, &Vid.hGrpBuf)) != OK)
return DispAvkErr(AvkRet, "AvkGrpBufCreate");
if ((AvkRet = AvkGrpBufCreate(hGrp, AVK_BUF_CAPTURE, AUD_BUF_SIZE,
AUD_BUF_GRAN, 1, &Aud.hGrpBuf)) != OK)
return DispAvkErr(AvkRet, "AvkGrpBufCreate");
// Create host RAM I/O buffers for retrieving
// video and audio frames and initialize them.
if ((Vid.pBufHead = MemAlloc(HOST_BUF_SIZE)) == NULL
|| (Aud.pBufHead = MemAlloc(HOST_BUF_SIZE)) == NULL)
return DispErr("CreateCaptureGroup",
"Unable to allocate host RAM I/O buffer");
Vid.BufDataCnt = (U32)0;
Aud.BufDataCnt = (U32)0;
if (!CreateVideoStream())
return FALSE;
if (!CreateAudioStream())
return FALSE;
if ((AvkRet = AvkGrpFlush(hGrp)) != OK)
return DispAvkErr(AvkRet, "AvkGrpFlush");
return TRUE;
}
// Create and format a video stream for the video capture buffer
static BOOL CreateVideoStream()
{
if ((AvkRet = AvkVidStrmCreate(Vid.hGrpBuf, 0, &Vid.hStrm)) != OK)
return DispAvkErr(AvkRet, "AvkVidStrmCreate");
// Format the video stream
Rtv20Args.xLen = Syncs[CaptureSync].xResRTV;
Rtv20Args.yLen = Syncs[CaptureSync].yResVid;
if ((AvkRet = AvkVidStrmFormat(Vid.hStrm,
6,
Syncs[CaptureSync].xResVid,
Syncs[CaptureSync].yResVid,
AVK_YUV9,
Syncs[CaptureSync].FrameRate,
AVK_RTV_2_0,
&Rtv20Args, sizeof(Rtv20Args), sizeof(Rtv20Args),
pVshBuf, VshSize, 64L * 1024L)) != OK)
return DispAvkErr(AvkRet, "AvkVidStrmFormat");
// Free the VSH buffer
MemFree(pVshBuf);
// Create a connector from the digitizer to the video stream
if ((AvkRet = AvkConnCreate(AVK_CONN_DIGITIZER, NULL, Vid.hStrm,
NULL, 0, &View.hConnDigi2Strm)) != OK)
return DispAvkErr(AvkRet,
"AvkConnCreate(Digitizer to Stream)");
// Create the connector from the video stream to the view
if ((AvkRet = AvkConnCreate(Vid.hStrm, NULL, View.hView,
&View.DstBox, AVK_PRE_MONITOR, &View.hConnStrm2View)) != OK)
return DispAvkErr(AvkRet, "AvkConnCreate (Stream to View)");
return TRUE;
}
// Create and format a audio stream for the audio capture buffer
static BOOL CreateAudioStream()
{
if ((AvkRet = AvkAudStrmCreate(Aud.hGrpBuf, 0, &Aud.hStrm)) != OK)
return DispAvkErr(AvkRet, "AvkAudStrmCreate");
// Format the audio stream
if ((AvkRet = AvkAudStrmFormat(Aud.hStrm, FRAME_RATE,
AUD_SAMPLE_RATE, AVK_ADPCM4, AVK_AUD_MIX, NULL, 0, 0)) != OK)
return DispAvkErr(AvkRet, "AvkAudStrmFormat");
return TRUE;
}
// Close the AVK session
BOOL EndAvk()
{
BOOL Ret = TRUE;
if (hAvk != HNULL)
{
if ((AvkRet = AvkEnd(hAvk)) != OK)
{
DispAvkErr(AvkRet, "AvkEnd");
Ret = FALSE;
}
}
if (Vid.pBufHead)
{
MemFree(Vid.pBufHead);
Vid.pBufHead = NULL;
}
if (Aud.pBufHead)
{
MemFree(Aud.pBufHead);
Aud.pBufHead = NULL;
}
// Null out all of the AVK handles
hAvk = hDev = HNULL;
hGrp = HNULL;
Vid.hGrpBuf = Vid.hStrm = HNULL;
Aud.hGrpBuf = Aud.hStrm = HNULL;
View.hView = HNULL;
View.hConnDigi2Strm = View.hConnStrm2View = HNULL;
ToState(ST_UNINITIALIZED);
return Ret;
}
[LISTING THREE]
//---- Windows AVK Capture Program - Recorder Control ------------
//---- Copyright Intel Corp. 1991, 1992, All Rights Reserved -----
// Sets a new state and enables/disables the applicable menu options
WORD ToState(WORD NewState)
{
WORD OldState;
if (NewState == ST_CAPTURING
|| NewState == ST_MONITORING
|| NewState == ST_INITIALIZED
|| NewState == ST_UNINITIALIZED)
{
if (State != NewState)
{
OldState = State;
State = NewState;
UpdateMenus(State);
return OldState;
}
else
return NewState;
}
return 0xffff;
}
// Checks whether the current state equals the caller's query state
BOOL IsState(WORD QueryState)
{
return State == QueryState;
}
// Returns the current state to the caller
WORD GetState()
{
return State;
}
// Toggle monitoring on and off based on user input
BOOL ToggleMonitor(VOID)
{
BOOL bRet;
switch (GetState())
{
case ST_INITIALIZED: bRet = MonitorOn(); break;
case ST_MONITORING: bRet = MonitorOff(); break;
default: bRet = TRUE; break;
}
return bRet;
}
// Turn on premonitoring
static BOOL MonitorOn()
{
if ((AvkRet = AvkConnEnable(View.hConnDigi2Strm, NOW)) != OK
|| (AvkRet = AvkConnEnable(View.hConnStrm2View, NOW)) != OK)
return DispAvkErr(AvkRet, "AvkConnEnable");
if ((AvkRet = AvkDeviceAudioIn(hDev, AVK_AUD_CAPT_LINE_INPUT,
AVK_MONITOR_ON)) != AVK_ERR_OK)
return DispAvkErr(AvkRet, "AvkDeviceAudioIn");
ToState(ST_MONITORING);
SetClipTimer();
return TRUE;
}
// Turn off premonitoring
static BOOL MonitorOff()
{
KillClipTimer();
if ((AvkRet = AvkConnHide(View.hConnStrm2View, NOW)) != OK
|| (AvkRet = AvkConnHide(View.hConnDigi2Strm, NOW)) != OK)
return DispAvkErr(AvkRet, "AvkConnHide");
if ((AvkRet = AvkDeviceAudioIn(hDev, AVK_AUD_CAPT_LINE_INPUT,
AVK_MONITOR_OFF)) != AVK_ERR_OK)
return DispAvkErr(AvkRet, "AvkDeviceAudioIn");
ToState(ST_INITIALIZED);
return TRUE;
}
// Toggles the capture on or off
BOOL ToggleCapture()
{
// If no file has been opened, return
if (!bAvioFileExists)
{
DispMsg("You must open a file before you can capture");
return TRUE;
}
switch(GetState())
{
case ST_MONITORING:
// If we are monitoring, turn on
// capture by starting the group
if ((AvkRet = AvkGrpStart(hGrp, NOW)) != OK)
return DispAvkErr(AvkRet, "AvkGrpStart");
ToState(ST_CAPTURING);
break;
case ST_CAPTURING:
// If we are already capturing, turn
// it off by pausing the group
if ((AvkRet = AvkGrpPause(hGrp, NOW)) != OK)
return DispAvkErr(AvkRet, "AvkGrpPause");
break;
default:
// Any other state, just do nothing - no error
break;
}
return TRUE;
}
[LISTING FOUR]
// ---- Windows AVK Capture Program - Write Captured Data to Disk ------
// ---- Copyright Intel Corp. 1991, 1992, All Rights Reserved ----------
extern CAPT Aud;
extern CAPT Vid;
extern I16 AvkRet;
extern HAVK hGrp;
extern WORD CaptureSync;
AVIO_SUM_HDR Avio;
BOOL bAvioFileExists = FALSE;
I16 AvioRet;
static BOOL ReadGrpBuf(CAPT *, BOOL *);
I16 DispAvioErr(char *pMsg);
VIDEO_SYNC Syncs[2] =
{
{ 128, 128, 240, AVK_NTSC_FULL_RATE, AVK_PA_NTSC },
{ 128, 153, 288, AVK_PAL_FULL_RATE, AVK_PA_PAL }
};
// Initialize the AVIO summary header and use it to create an AVSS file.
BOOL OpenAvioFile(char *pFileSpec)
{
AVIO_VID_SUM FAR *pVid;
AVIO_AUD_SUM FAR *pAud;
VIDEO_SYNC *pSync;
if (!*pFileSpec)
return DispErr("OpenAvioFile", "No file spec");
// Clear out the Avio structure.
_fmemset((char FAR *)&Avio, 0, sizeof(Avio));
// Initialize the structure.
Avio.SumHdrSize = sizeof(AVIO_SUM_HDR);
Avio.VidSumSize = sizeof(AVIO_VID_SUM);
Avio.AudSumSize = sizeof(AVIO_AUD_SUM);
Avio.StrmCnt = 2;
Avio.VidCnt = 1;
Avio.AudCnt = 1;
if ((AvioRet = AvioFileAlloc((AVIO_SUM_HDR FAR *)&Avio)) < 0)
return DispAvioErr("AvioFileAlloc");
// Fill out the video stream substructure.
pSync = &Syncs[CaptureSync]; // sync data (NTSC or PAL)
pVid = Avio.VidStrms;
pVid->StrmNum = 0; // video stream number
pVid->Type = AVL_T_CIM; // compressed data
pVid->SubType = AVL_ST_YVU; // packed data
pVid->StillPeriod = AVL_CIM_RANDOM_STILL; // freq of still frames
pVid->xRes = pSync->xResVid << 1; // x resolution
pVid->yRes = pSync->yResVid; // y resolution
pVid->BitmapFormat = AVK_BM_9; // bitmap format
pVid->FrameRate = pSync->FrameRate; // frame rate
pVid->PixelAspect = pSync->PixelAspect; // NTSC aspect ratio
pVid->AlgCnt = 1; // only one algorithm
pVid->AlgName[0] = AVK_RTV_2_0; // RTV 2.0 compression alg
// Fill out the audio stream substructure.
pAud = Avio.AudStrms;
pAud->StrmNum = 1; // audio stream number
pAud->LeftVol = 100; // left channel volume = 100%
pAud->RightVol = 100; // right channel volume = 100%
pAud->FrameRate = pSync->FrameRate; // frame rate
pAud->SamplesPerSecond = AUD_SAMPLE_RATE; // audio samples-per-second
pAud->AudChannel = AVK_AUD_MIX; // both speakers
pAud->AlgCnt = 1; // number of algorithms
pAud->AlgName[0] = AVK_ADPCM4; // audio ADPCM4 algorithm
// Now create the file with all standard AVSS headers.
if ((AvioRet = AvioFileCreate((char far *)pFileSpec,
(AVIO_SUM_HDR FAR *)&Avio, OF_CREATE)) < 0)
return DispAvioErr("AvioFileCreate");
bAvioFileExists = TRUE;
return TRUE;
}
// This function retrieves frames from the Group Buffers
// in VRAM and writes them out to an AVSS file on disk.
BOOL CaptureAvioData()
{
static BOOL bInUse = FALSE;
AVIO_FRM_HDR FAR *pFrmHdr[2]; // frame header pointers
// for video & audio
BOOL bDataRead;
int Ret;
U32 VidFrmSize, AudFrmSize;
WORD Count;
if (bInUse)
return TRUE;
bInUse = TRUE;
// Error if no buffers have been allocated.
if (!Vid.pBufHead || !Aud.pBufHead)
return DispErr("CaptureAvioData",
"NULL host RAM buffer pointer");
Count = CAPTURE_LOOPS;
do {
// Init the data-read flag
bDataRead = FALSE;
if (!Vid.BufDataCnt)
{
if (!ReadGrpBuf(&Vid, &bDataRead))
return FALSE;
}
if (!Aud.BufDataCnt)
{
if (!ReadGrpBuf(&Aud, &bDataRead))
return FALSE;
}
while (Vid.BufDataCnt && Aud.BufDataCnt)
{
pFrmHdr[0] = (AVIO_FRM_HDR FAR *)Vid.pBufCurr;
pFrmHdr[1] = (AVIO_FRM_HDR FAR *)Aud.pBufCurr;
if ((Ret = AvioFileFrmWrite((AVIO_SUM_HDR FAR *)&Avio,
pFrmHdr)) < 0)
return DispAvioErr("AvioFileFrmWrite");
VidFrmSize = (U32)sizeof(AVIO_FRM_HDR)
+ pFrmHdr[0]->StrmSize[0];
Vid.pBufCurr += (WORD)VidFrmSize;
Vid.BufDataCnt -= VidFrmSize;
AudFrmSize = (U32)sizeof(AVIO_FRM_HDR)
+ pFrmHdr[1]->StrmSize[0];
Aud.pBufCurr += (WORD)AudFrmSize;
Aud.BufDataCnt -= AudFrmSize;
}
} while (bDataRead && Count--);
bInUse = FALSE;
return TRUE;
}
// Read newly captured frames from an AVK Group Buffer
// into one of the application's host RAM buffers
static BOOL ReadGrpBuf(CAPT *pCapt, BOOL *pbDataRead)
{
// Only refill the buffer if it is empty
if (!pCapt->BufDataCnt)
{
// Retrieve a buffer of frames.
if ((AvkRet = AvkGrpBufRead(pCapt->hGrpBuf, HOST_BUF_SIZE,
pCapt->pBufHead, &pCapt->BufDataCnt, AVK_ENABLE)) != OK)
return DispAvkErr(AvkRet, "AvkGrpBufRead");
// Set data-read flag if we read any data.
*pbDataRead = pCapt->BufDataCnt == (U32)0 ? FALSE : TRUE;
// Point back to start of buffer.
pCapt->pBufCurr = pCapt->pBufHead;
}
return TRUE;
}
// Update and lose an AVSS file using AVKIO.
BOOL CloseAvioFile()
{
if (bAvioFileExists == TRUE)
{
// Update the file's header with current information that
// AVKIO keeps in the Avio summary header.
if ((AvioRet = AvioFileUpdate((AVIO_SUM_HDR FAR *)&Avio, 0)) < 0)
return DispAvioErr("AvioFileUpdate");
// Close the file.
if ((AvioRet = AvioFileClose((AVIO_SUM_HDR FAR *)&Avio)) < 0)
return DispAvioErr("AvioFileClose");
bAvioFileExists = FALSE;
}
return TRUE;
}